<template>
  <div>
    <div v-show="message" class="bg" @click.stop="close"></div>
    <transition>
    <div class="message_box" v-show="message">
      <div class="subject">
        <!-- 顶部 -->
        <div class="top">
          <!-- 用户头像、昵称 -->
          <div class="user_message">
            <div class="icon">
              <div v-if="!userinfolist" class="iconfont icon-yonghu-yuan" @click="$router.push('/usermessage').catch(() => {}),(message = false)"></div>
              <div v-else @click="$router.push('/usermessage').catch(() => {}),(message = false) ">
                <img :src="userinfolist.avatarUrl" alt="" />
              </div>
              <div class="username">
                <span v-if="userinfolist">{{ userinfolist.nickname }}</span>
                <span v-else>昵称</span>
                <span class="iconfont icon-icon-test"></span>
              </div>
            </div>
          </div>
        </div>

        <!-- 会员中心 -->
        <div class="vip">
          <div class="vip_top">
            <h3>开通黑胶VIP</h3>
            <div>会员中心</div>
          </div>
          <p>立享超21项专属特权 ></p>
          <p>双十一预约中! 5折秒杀明日开启</p>
        </div>

        <div class="listbox">
          <div class="list">
            <div class="item">
              <span>我的消息</span><span class="iconfont icon-icon-test"></span>
            </div>
            <div class="item">
              <span>云贝中心</span><span class="iconfont icon-icon-test"></span>
            </div>
            <div class="item">
              <span>创作者中心</span
              ><span class="iconfont icon-icon-test"></span>
            </div>
          </div>
          <div class="list">
            <p>音乐服务</p>
            <div class="item">
              <span>云村有票</span><span class="iconfont icon-icon-test"></span>
            </div>
            <div class="item">
              <span>商城 </span><span class="iconfont icon-icon-test"></span>
            </div>
            <div class="item">
              <span>游戏专区</span><span class="iconfont icon-icon-test"></span>
            </div>
          </div>
          <div class="list">
            <div class="item quit">退出登录</div>
          </div>
        </div>
      </div>
    </div>
    </transition>
  </div>
</template>

<script>
import Bus from "../../api/Bus";
import { getUserdetail } from "../../api/userinfo";
export default {
  created() {
    Bus.$on("userinfo", (val) => {
      this.message = val;
      // console.log(this.message);
    });
    let usid = window.localStorage.getItem("uid");
    console.log(usid);
    getUserdetail({uid:usid}).then((data) => {
      console.log(data)
      // console.log(data.profile)
      this.userinfolist = data.profile;
      // console.log(this.userinfolist);
    });
  },
  data() {
    return {
      message: null,
      userinfolist: [],
    };
  },
  methods: {
    close() {
      this.message = false;
      console.log(this.message);
    },
  },
};
</script>

<style lang="less">
.v-leave-to,
.v-enter {
  opacity: 0;
  transform: translateX(-150px);
}
/* .v-leave-active 离开过度效果 */
/* .v-enter-active 进入过度效果 */
.v-leave-active,
.v-enter-active {
  transition: all 0.8s ease;
}

  .bg {
    width: 100%;
    height: 100%;
    position: fixed;
    background: rgba(1, 1, 1, 0.6);
    z-index: 9;
    top: 0px;
  }

.message_box {
  width: 95%;
  height: 100%;
  position: fixed;
  z-index: 9;
  top: 0px;
  .subject {
    width: 91%;
    height: 100%;
    background-color: #f6f6f6;
    padding: 50px 15px 0px 15px;
    position: relative;
    top: 0;
    z-index: 10;
    .top {
      position: absolute;
      left: 0px;
      top: 0px;
      display: flex;
      width: 100%;
      height: 50px;
      line-height: 50px;
      padding: 0 15px;
      box-sizing: border-box;
      background-color: #fff;
      .user_message {
        width: 100%;
        .icon {
          display: flex;
          width: 100%;
          align-items: center;
          .iconfont {
            font-size: 30px;
          }
          .username {
            margin-left: 8px;
            .iconfont {
              font-size: 14px;
            }
          }
          img {
            width: 30px;
            height: 30px;
            border-radius: 50%;
          }
        }
      }
    }
    .vip {
      width: 100%;
      height: 115px;
      padding: 12px 16px;
      box-sizing: border-box;
      margin-top: 14px;
      background-color: #343434;
      border-radius: 13px;
      .vip_top {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        h3 {
          color: #f9e7e2;
        }
        div {
          padding: 0 9px;
          border-radius: 17px;
          height: 28px;
          line-height: 28px;
          border: 2px solid #6b6567;
          font-size: 12px;
          color: #af9b9a;
        }
      }
      p:nth-of-type(1) {
        margin-top: 5px;
        margin-bottom: 20px;
      }
      p {
        font-size: 12px;
        color: #7c7772;
      }
    }

    .listbox {
      width: 100%;
      font-size: 14px;
      .list {
        width: 100%;
        margin-top: 14px;
        border-radius: 8px;
        overflow: hidden;
        .item {
          box-sizing: border-box;
          background-color: #fff;
          padding: 0 15px;
          height: 52px;
          line-height: 52px;
          margin-top: 1px;
          display: flex;
          justify-content: space-between;
        }
        p {
          box-sizing: border-box;
          background-color: #fff;
          padding: 0 15px;
          height: 40px;
          line-height: 40px;
          color: #9e9e9e;
          font-size: 13px;
        }
        .quit {
          text-align: center;
          color: red;
        }
      }
    }
  }
}
</style>